package keeto.com.vn.bms.ui.widget;

import keeto.com.vn.bms.model.NotificationModel;
import keeto.com.vn.bms.ui.activity.CreateScheduleActivity;
import keeto.com.vn.bms.ui.activity.R;
import keeto.com.vn.bms.utils.BMSSharedPreferences;
import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.Window;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;

public class BMSDialog extends Dialog implements android.view.View.OnClickListener{

	private Context context;
	private TextView tvTitle;
	private TextView tvContent;
	private ImageView imgClose;
	private NotificationModel model;
	private BMSSharedPreferences preferences;

	protected BMSDialog(Context context, boolean cancelable,
			OnCancelListener cancelListener) {
		super(context, cancelable, cancelListener);
	}

	public BMSDialog(Context context, int theme) {
		super(context, theme);
	}

	public BMSDialog(Context context, NotificationModel model) {
		super(context);
		this.context = context;
		this.model = model;
		preferences = new BMSSharedPreferences(context);
	}

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		setContentView(R.layout.dialog_layout);
		tvTitle = (TextView)findViewById(R.id.tv_title_notify);
		tvContent = (TextView)findViewById(R.id.tv_content_notify);
		imgClose = (ImageView)findViewById(R.id.img_close_title_dialog);

		if(model != null){
			tvTitle.setText(model.getActivitiTitle());
			tvContent.setText(model.getNotifyContent());
			Log.e("TGGGGGGGGGGGGGGGGG", "TAGGGGGGGGGGGGGGG");
			//kien code
			tvContent.setOnClickListener(new View.OnClickListener() {
				@Override
				public void onClick(View v) {
					if(model.getObjId().equals("")){
						Log.e("ho ho ActivitiId", model.getObjId()+".");
					} else {
						Log.e("ho ho ActivitiId", model.getObjId()+".");
						CreateScheduleActivity.actionLaunchSergery(context, model.getObjId());
						dismiss();
					}
					
				}
			});
		}
		imgClose.setOnClickListener(this);
	}

	@Override
	public void onClick(View v) {
		// TODO Auto-generated method stub
		switch (v.getId()) {
		case R.id.img_close_title_dialog:
			this.dismiss();
			break;

		default:
			break;
		}
	}
}
